<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,user-scalable=no">
    <meta name="keywords" content="xx,xx,xx"/>
    <meta name="description" content="yyyyyyy"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta property="qc:admins" content="70003766576320416375"/>
    <meta name="format-detection" content="telephone=no">
    <title>提现</title>
    <link rel="stylesheet" href="../css/base/jquery-ui-1.10.3.css" type="text/css">
    <link rel="stylesheet" href="../plugin/bootstrap-3.3.7/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/job.css">
    <link rel="stylesheet" href="../css/withdraw.css">
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>
<body style="background: #f1f1f1">
<div class="container-fluid" style="background-color: #f7f7f9">
    <!--header start-->
    <div class="row header">
        <div><span id="back" class="glyphicon  glyphicon-chevron-left" style="float: left;cursor: pointer;"></span>提现
        </div>
    </div>
    <!--header end-->

    <!--content start-->
    <div class="row content">
        <div class="show-box withdraw">
            <h5>
                <span>到帐支付宝：</span>
                <span style="margin-left: 5px"><input id="alipay" type="text"
                                                      style=" color: #006699;  border: 0;background: inherit;outline: 0;font-size: 15px"
                                                      placeholder="请输入账号"></span>
            </h5>
            <h5>
                <span>提现金额</span>
                <span class="glyphicon glyphicon-yen" style=" font-size: 20px;">
                    <input type="text" id="cash">
                </span>
            </h5>
            <h5>
                 <span style="font-size: 18px;">
                    <small>可用余额<span class="glyphicon glyphicon-yen" id="money"></span>皇币（元）</small>
                    <small id="withdraw" style="margin-left: 20px;color: #006699;cursor: pointer;">全部提现</small>
                </span>
                <small id="alert">提现金额不能大于总余额</small>
            </h5>
            <h5>
                <button class="btn btn-button" id="sign-up" disabled>确认</button>
            </h5>
        </div>
    </div>
    <!--content end-->
</div>
</body>
<script src="../js/common/jquery-2.1.4.min.js"></script>
<script src="../js/index.js"></script>
<script src="../plugin/bootstrap-3.3.7/dist/js/bootstrap.min.js"></script>
<script src="../js/common/common.js"></script>
<script>
    $(function () {

        var url1 = server + '/server/wallet/home.json';
        $.post(url1,function (data) {
            $('#money').text(data.data.amount);
        });


        var cash = $('#cash');
        var alipay = $('#alipay');
        var btn = $('#sign-up');
        alipay.focus();
        cash.blur(function () {
            change_cash();
        });


        $('#withdraw').click(function () {
            var $get_cash = $(this).prev().find('span').text();
            $('#cash').val($get_cash);
            change_cash();
        });


        btn.click(function () {

            var account = $('#alipay').val();
            var amount = $('#cash').val();
            var url = server + '/server/deposit/save.json';
            var json = {"amount":amount,"account":account};

            $.post(url,json, function (data) {


                var flag = data.code;//判断提现是否成功
                if (flag == 20000) {
                    alert('体现成功，我们会尽快处理');
                    location.replace('personal.html');
                }

                else if(flag == 14003){
                    alert('身份证未认证');
                    window.location.reload();
                }
                else if(flag == 11001){
                    alert('账户无效');
                    window.location.reload();
                }
                else if(flag == 14001){
                    alert('余额不足');
                    window.location.reload();
                }
                else {
                    alert('提现功能出错，请及时反馈！');
                    window.location.reload();
                }
            });


        });

        function change_cash() {
            var $get_cash = cash.parents('h5').next().find('small>span').text();
            if (parseInt(cash.val()) > parseInt($get_cash)) {
                $('#alert').css('display', 'block');
                btn.attr('disabled', true);
            }
            else {
                $('#alert').css('display', 'none');
                if ($('#cash').val() !== '') {
                    btn.attr('disabled', false);
                }
            }
        }


    });
</script>
</html>